class ShopWindowControl {
	private static _inst: ShopWindowControl;
	private _shopWindow: Carrun.UI_shopWindow;
	public buyList: Array<ShopItemModel>;
	public constructor() {
		this._shopWindow = MainSceneCotrol.inst().mainScene.m_shopWindiw;
		this.init();
	}
	public static inst(): ShopWindowControl {
		if (!this._inst)
			this._inst = new ShopWindowControl();

		return this._inst;
	}

	public get shopWindow() {
		if (!this._shopWindow)
			this._shopWindow = MainSceneCotrol.inst().mainScene.m_shopWindiw;
		return this._shopWindow;
	}

	public init() {
		this._shopWindow.m_closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.closeShopWinBtnClick, this)
	}
	private closeShopWinBtnClick() {
		this._shopWindow.visible = false;
	}
	public openShopWin() {
		this._shopWindow.visible = true;
	}

	public setCarList() {
		this.buyList = [];
		for (var q: number = 0; q < MainSceneCotrol.inst().carDatasAry.length; q++) {
			this.shopWindow.m_buyCarList.addItem(Carrun.UI_shopItem.URL);
			this.buyList.push(new ShopItemModel(this.shopWindow.m_buyCarList.getChildAt(q) as Carrun.UI_shopItem,MainSceneCotrol.inst().carDatasAry[q]));
		}
	}
}